from selenium.webdriver.remote.webdriver import WebDriver
from appium import webdriver

from page import add_imgs
from page.add_imgs import AddImgs


class SearchPage:
    def __init__(self, driver):
        self.driver = driver
    def search(self, keyword):
        el4 = self.driver.find_element_by_id("com.xqxc.customer:id/et_search")
        print(self.driver)
        a=AddImgs(self.driver)
       # AddImgs.add_img(self,self.driver)
        # driver=self.driver
        # print(driver)
        # images=[]
        #a.add_img(self,driver,images)


        el4.click()
        el4.send_keys(keyword)
        self.driver.keyevent("66")
        return self
    def get_text(self):
        el5 = self.driver.find_element_by_xpath(
            "//android.support.v7.app.ActionBar.Tab[@content-desc=\"全部\"]/android.widget.TextView")
        el5.click()
        el6 = self.driver.find_element_by_xpath(
            "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.support.v4.view.ViewPager/android.view.ViewGroup/android.support.v4.view.ViewPager/android.widget.LinearLayout/android.view.ViewGroup/android.support.v7.widget.RecyclerView/android.widget.RelativeLayout[1]/android.view.ViewGroup/android.widget.TextView[2]").text
        return el6
